package day09.ArrayListTest;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class ALSoldier {
    public static void main(String[] args) {
        System.out.println("士兵数量:");
        int n = new Scanner(System.in).nextInt();
        ArrayList<Object> al = new ArrayList<>();
        for (int i = 0; i < n; i++){
            Soldier s = new Soldier();
            s.id = i + 1;
            al.add(s);
        }

        while(al.size() != 0){
            for(Iterator it = al.iterator();it.hasNext();){
                Soldier s = (Soldier) it.next();
                s.attack();
                if(s.blood == 0){
                    it.remove();
                }
            }
            System.out.println("士兵数量:"+al.size());
        }
    }
}
